﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpMap.Data;
using SharpMap.Layers;
using SharpMap.Data.Providers;
using SharpMap;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace BLL
{
    public class DaGiac
    {
        

        public static Map KhoiTaoDaGiac(string[] maDaGiac)
        {
            SharpMap.Map myMap = new SharpMap.Map(new Size(600, 800));
            myMap.MinimumZoom = 15; //Minimum zoom allowed
            myMap.BackColor = Color.LightBlue;
            myMap.MaximumZoom = 360;

            //string[] a = new string[4] { "DG1", "DG2","DG3","DG4" };
            VectorLayer daGiacLayer = new VectorLayer("Da Giac Layer");
            //myLayer.DataSource = new SharpMap.Data.Providers.Oracle("Demo","981172","orcl","cola_markets","Shape","MKT_ID");
            //string conStr = "User Id=qldat;Password=oracle;Data Source=test";
            string conStr = "User Id =DatDai;Password=oracle;Data Source=LVTN";
            SharpMap.Data.Providers.Oracle dagiac;
            dagiac = new SharpMap.Data.Providers.Oracle(conStr, "dagiac", "hinhdang", "madagiac");
            //dagiac.DefinitionQuery = "madagiac='"+maDaGiac+"'";
            string temp = "";
            for (int i = 0; i <maDaGiac.Count(); i++)
            {
                if (i < maDaGiac.Count()-1)
                    temp += maDaGiac[i] + "','";
                else
                    temp += maDaGiac[i];
            }
                dagiac.DefinitionQuery = "madagiac in ('"+ temp+ "')";
            //dagiac.DefinitionQuery = "maDaGiac in (SELECT TD.MADAGIAC FROM GCN_SDD_CHUSUDUNG GCN JOIN THUADAT_GCN_SDD TD_GCN ON GCN.MaGCN = TD_GCN.MaGCN, CHUSUDUNG CSD, THUADAT TD WHERE GCN.MACSD= (SELECT MACSD FROM CHUSUDUNG WHERE SO_CMND_QDTL_GPKD='210038969') AND GCN.MACSD=CSD.MACSD AND TD.MATHUADAT=TD_GCN.MATHUADAT)";
            daGiacLayer.DataSource = dagiac;
            daGiacLayer.Style.Outline = Pens.Black;
            daGiacLayer.Style.Fill = new SolidBrush(Color.Green);
            daGiacLayer.Style.EnableOutline = true;

            myMap.Layers.Add(daGiacLayer);



            myMap.MaximumZoom = 500;
            myMap.BackColor = Color.LightBlue;

            myMap.ZoomToExtents(); // = 360;
            return myMap;
        }
    }
}
